package com.lianbang.pharmacy.module.main

import android.app.Activity
import android.content.Context
import android.content.Intent
import androidx.lifecycle.Observer
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import cn.ubest.mvvmcore.base.BaseActivity
import cn.ubest.mvvmcore.base.BaseListActivity
import cn.ubest.mvvmcore.databinding.IncludeToolbarListWithRefreshBinding
import cn.ubest.mvvmcore.utils.ResourcesUtils
import com.chad.library.adapter.base.BaseQuickAdapter
import com.lianbang.pharmacy.R
import com.lianbang.pharmacy.adapter.SupplierListAdapter
import com.lianbang.pharmacy.bean.MedicineInfoBean
import com.lianbang.pharmacy.bean.MedicineSupplierListBean
import com.lianbang.pharmacy.bean.SupplierListBean
import com.lianbang.pharmacy.vm.MedicineVM
import com.lianbang.pharmacy.vm.SupplierVM

/**
 * Created by maoqi on 2020/11/22.
 */
class SupplierListActivity :
    BaseListActivity<SupplierVM, IncludeToolbarListWithRefreshBinding, SupplierListBean>() {

    companion object {
        fun start(context: Context?) {
            context?.also {
                val starter = Intent(it, SupplierListActivity::class.java)
                if (it !is Activity) {
                    starter.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
                }
                it.startActivity(starter);
            }

        }
    }

    override fun initLayout(): Int {
        return R.layout.include_toolbar_list_with_refresh
    }

    override fun initData(intent: Intent) {
        super.initData(intent)
    }

    override fun setToolbarTitle(): String? {
        return "优质供应商"
    }

    override fun initView() {
        super.initView()
        mBinding.llContent.setBackgroundColor(ResourcesUtils.getColor("#f9f9f9"))
        val rvList = findViewById<RecyclerView>(R.id.rv_list)
        rvList.setPadding(0, ResourcesUtils.getDimens(R.dimen.dp_15), 0, 0)
    }

    override fun loadData() {
        mViewModel.loadData(true)
    }

    override fun initAdapter(): BaseQuickAdapter<SupplierListBean, *> {
        return SupplierListAdapter()
    }

}